public class num110 {
    public boolean isBalanced(TreeNode root) {
        if(root == null){
            return true;
        }
        int left = hight(root.left);
        int right = hight(root.right);
        int abs = Math.abs(left - right);
        return abs <= 1 && isBalanced(root.left) && isBalanced(root.right);
    }
    public int hight(TreeNode root){
        return root == null? 0 : 1 + Math.max(hight(root.left),hight(root.right));
    }
}
